package com.example.springbootredis.dao;

import com.example.springbootredis.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudentDao {

    @Select("SELECT * FROM students")
    List<Student> getAllStudents();

    @Select("SELECT * FROM students WHERE id = #{id}")
    Student getStudentById(int id);

    @Insert("INSERT INTO students(name, age) VALUES (#{name}, #{age})")
    void addStudent(Student student);

    @Update("UPDATE students SET name = #{name}, age = #{age} WHERE id = #{id}")
    void updateStudent(Student student);

    @Delete("DELETE FROM students WHERE id = #{id}")
    void deleteStudent(int id);
}

